/************************************************************************************
**  
* @copyright (c) 2015-, Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file     duye_cap_netlayer_service.h
* @version     
* @brief      
* @author   
* @date     2013-01-09
* @note 
*
*  1. 2018-01-09 created this file
* 
*/
#pragma once

#include <string>
#include <map>

#include <duye_type.h>
#include <duye_cap_service_base.h>
#include <duye_cap_packet.h>
#include <duye_cap_linklayer_service.h>

namespace duye {

/**
 * @brief net layer listener interface
 */
class NetLayerListener : public DataServiceListener {
public:
	virtual ~NetLayerListener() {}
	virtual int32 onNetLayerPacket(const PacketReference& pktRef) = 0;
};

typedef std::map<NetLayerListener*, FilterRule*> NetLayerListenerMap;

/**
 * @brief net layer server interface
 */
class NetLayerService : public CapDataService, public LinkLayerListener, public Singleton<NetLayerService> {
public:
	NetLayerService();
	virtual ~NetLayerService();

	// implementation WdpiService interface 
	virtual bool start();
    // implementation WdpiService interface
	virtual bool stop();
	// implementation WdpiService interface
	virtual bool run();	
    // implementation WdpiService interface
    virtual bool addListener(DataServiceListener* listener, const FilterRule* filterRule = NULL);
    // implementation WdpiService interface
    virtual bool delListener(DataServiceListener* listener);

	// implementation link layer listener interface
	virtual int32 onLinkLayerPacket(const PacketReference& pktRef);
    
private:
    NetLayerListenerMap m_listenerMap;
};

}
